<template>
    <div class="flex items-center">
        <el-icon class="mr-2 text-blue-500" v-if="modelValue" :size="21">
            <component :is="modelValue" />
        </el-icon>
        <el-select :modelValue="modelValue" @change="handleChange" placeholder="請選擇圖標" filterable>
            <el-option v-for="item in icons" :key="item" :label="item" :value="item">
                <div class="flex items-center justify-between">
                    <el-icon :size="18">
                        <component :is="item" />
                    </el-icon>
                    <span class="text-gray-500">{{ item }}</span>
                </div>
            </el-option>
        </el-select>
    </div>
</template>
  
<script setup>
import { ref } from "vue";
import * as iconList from "@element-plus/icons-vue";
defineProps({
    modelValue: String,
});
const icons = ref(Object.keys(iconList));

const emit = defineEmits(["update:modelValue"]);

const handleChange = (e) => {
    emit("update:modelValue", e);
};
</script>
  